package com.shxy.controller;

import com.shxy.common.ApiResult;
import com.shxy.controller.ui.SalaryBean;
import com.shxy.entity.Salary;
import com.shxy.entity.common.enums.EmployeeType;
import com.shxy.util.ExcelUtils;
import lombok.extern.java.Log;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.*;

/**
 * 工资管理控制器
 */
@Log
@RestController
@RequestMapping("/v2/salary")
public class SalaryController {

    /**
     * 导入员工
     * @param date
     * @return
     */
    @PostMapping("/init/salary")
    public ApiResult importEmployees(Date date) {
        return ApiResult.success(date);
    }

    /**
     * 导入数据
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public ApiResult importSalaryList(MultipartFile file) {
        List<SalaryBean> salaries = ExcelUtils.readExcel(null, SalaryBean.class, file);
        return ApiResult.success(salaries);
    }

    /**
     * 保存工资信息
     * @param salary
     * @return
     */
    @PostMapping("/save")
    public ApiResult save(@RequestBody SalaryBean salary) {
        return ApiResult.success(salary);
    }

    /**
     * 获取工资列表
     * @return
     */
    @GetMapping("/list/{salaryDate}")
    public ApiResult getList(@PathVariable(name = "salaryDate") String salaryDate) {
        return ApiResult.success();
    }
}
